﻿using System;
using System.Collections.Generic;
using System.Text;
using Infrastructure.Lib.Core;
using Infrastructure.Lib.Core.NPOIHelper;

namespace CrmSpider.Model
{
    public class TraceRecordModel
    {
        [ColumnType(Name = "跟踪客户")]
        public string CustomerName { get; set; }

        [ColumnType(Name = "跟踪项目")]
        public string ProjectName { get; set; }

        [ColumnType(Name = "联系人")]
        public string Contact { get; set; }

        [ColumnType(Name = "跟踪人")]
        public string Tracer { get; set; }

        [ColumnType(Name = "跟踪时间")]
        public string TraceTime { get; set; }

        [ColumnType(Name = "跟踪内容")]
        public string TraceContent { get; set; }

        public TraceRecordModel(string recordStr)
        {
            var items = new List<string>(recordStr.Matches("(?<=<p>)[\\s\\S]+?(?=</p>)"));
            if (items.Count < 3) return;
            CustomerName = items[0].Substring2("跟踪客户：</strong>", "<strong>");
            ProjectName = items[0].Substring2("跟踪项目：</strong>", "<strong>");
            Contact = items[0].Substring2("联系人：</strong>", "\r",true);

            Tracer = items[1].Substring2("跟踪人：</strong>", "<strong>");
            TraceTime = items[1].Substring2("跟踪时间：</strong>", "\r",true);

            TraceContent = items[2].ReplaceHtmlTag().Trim('\r','\n',' ');

        }
    }
}
